<template>
  <div @click.prevent="bodyClick" >
    <div class="head-all" ><cmHeader ref="bannerChild" :searchShow="searchShow"></cmHeader></div>
    <!--banner导航组件-->
    <bannerNav :bannerNav="bannerNav" ></bannerNav>
    <!--中间部分-->
    <div class="mainContentWrap minWidth">
      <div class="headImg textCenter f-tb"> <div>LATEST WAREHOUSING</div> <div>最新如入库</div></div>
      <!--<div class="controlWrapper">-->
        <!--<div @click="do_control">-->
          <!--<span v-if="controlShow">收起 <img src="" alt=""></span>-->
          <!--<span v-if="!controlShow">筛选 <img src="" alt=""></span>-->
        <!--</div>-->
        <!--&lt;!&ndash; 成果库选择查询组件&ndash;&gt;-->
        <!--<selectCGList v-if="controlShow"></selectCGList>-->
      <!--</div>-->
    </div>
    <!--最新入库展示列表组件-->
    <div class="minWidth" >
      <warehouse :newList="getHomeData.ResultShowLastList"></warehouse>
    </div>
    <!--热点组件-->
    <div class="headImg textCenter f-tb"> <div>HOTSPOT</div> <div>热点</div></div>
    <hotspotList  ></hotspotList>
    <!--统计中心-->
    <div class="headImg textCenter f-tb"> <div>STATISTICAL CENTER</div> <div>统计中心</div></div>
    <centerList :ResultShowCount="getHomeData.ResultShowCount"></centerList>
    <!--页脚组件-->
    <div class="foot ">
        <zcFooter></zcFooter>
    </div>
  </div>

</template>
<script>
import cmHeader from './common/cm_header'
import zcFooter from './common/zcFooter'
import selectCGList from './common/cm_selectCGList' //成果库选择查询组件
import bannerNav from './cgkHome/bannerNav'  //导航的选项卡
import warehouse from './cgkHome/latestWarehousing' //最新入库展示列表组件
import hotspotList from './cgkHome/hotspotList'  //中间热点组件
import centerList from './cgkHome/centerList' //统计中心组件

export default {
  inject:['reload'],
  components: {
    cmHeader,
    zcFooter,
    selectCGList,
    bannerNav, //导航的选项卡
    warehouse,
    hotspotList,
    centerList
  },
  data() {
    return {
      controlShow: false,//筛选控制按钮
      searchShow: true,
      bannerNav:{},
      homeData:{}
    }
  },
  created() {
    let test = [];
    test = this.navList
    this.def_getNavList()//获取首页内容展示
    this.do_getNavData()//获取首页导航数据

  },

  methods: {
    // do_control(){
    //   this.controlShow=!this.controlShow
    //   this.confirm=true
    // },
    bodyClick(){
        this.$refs.bannerChild.do_getSearchList2()
    },
      def_getNavList(){//获取首页内容
      let me = this;
         me.$ZcPublic.zcServer.Post({
        IsNeedLogin: 'false',
        Paras: {
          Name: 'Vue_resultLib',
          action: "getP_ResoutShowHome",
          Data: {
            organCode:me.$ZcPublic.OrganCode
          }
        },
        Callback:   me.cb_def_getNavList,
        Scope: me,
      });
    },

/*回调*/
     cb_def_getNavList(resJson,scoped){
     console.log('首页内容展示数据',resJson)
      if(resJson.success){
        this.$store.commit("setHomeData", resJson.data)//把首页数据存到vuex中
      }else {
        this.$confirm({
          type:'错误',
          msg:resJson.msg,
          btn:{
            ok:'yes'

          }
        })
      }
    },
    do_getNavData(){
      let me = this;
        me.$ZcPublic.zcServer.Post({
        IsNeedLogin: 'false',
        Paras: {
          Name: 'Vue_resultLib',
          action: "getResultShowTotalCount",
          Data: {
            organCode:me.$ZcPublic.OrganCode
          }
        },
        Callback: me.cb_def_getNavData,
        Scope: me,
      });
    },
    cb_def_getNavData(resJson,scoped){
       console.log('首页导航',resJson)
      try {
        if(!resJson.success){
          this.$confirm({
            type:'错误',
            msg:resJson.msg,
            btn:{
              ok:'yes'

            }
          })
        }else {
          this.bannerNav=resJson.data
        }
      }catch (e) {

      }
    }
  },
  computed:{
    getHomeData(){ //获取首页内容展示数据
      console.log('this.$store.getters.getHomeData',this.$store.getters.getHomeData)
      return this.$store.getters.getHomeData;
    }
  }

}
</script>
<style scoped>
  .headImg{
    height: 140px;
    font-family: "造字工房朗倩";
    font-weight: 900;
    box-sizing: border-box;
    padding-bottom: 10px;
  }
  .headImg div:first-child{
    color: #CBCBCB;
    font-size: 24px;
  }
  .headImg div:last-child{
    font-size:20px;
    color: #3F90FD;
    position: relative;
  }
  .headImg div:last-child:after{
    content: '';
    width: 30px;
    height: 3px;
    background-color: #3F90FD;
    position: absolute;
    left: 50%;
    margin-left: -15px;
    bottom: -7px;
  }
  .controlWrapper>div span{
    display: inline;
    cursor: pointer;
  }
  .controlWrapper{
    text-align: right;
    padding: 10px 0;
  }
.foot{
  margin-top: 80px !important;
}

</style>


